﻿package org.dm.3d.Actions.object 
{
	
	/**
	 * ...
	 * @author Scott
	 */
	public class Tower 
	{
		private var goalPos:Vector.<Vector3D>;
		
		public function Tower() 
		{
			this.isUsed = true;
			goalPos = new Vector.<Vector3D>;
			var points:Vector.<int> = Vector.<int>([]);
			for (var i:uint = 0; i < points.length/3; i++)
			{
				goalPos.push(new Vector3D(points[3 * i]*5, -points[3 * i + 1]*5,-points[3 * i + 2]*5));
			}
		}
		public override function update(items:Array,time:Number,num:uint):void 
		{
			var goalNum:uint = goalPos.length;
			var g1:Vector3D;
			var g2:Vector3D;
			goalNum = goalNum > 0?goalNum:0;
			for (var i:uint = 0; i < goalNum; i++)
			{
				items[i].visable = true;
				g1 = items[i].pos;
				g2 = goalPos[i];
				//goaldistance = items[i].pos.subtract(goalPos[i]).clone();
				items[i].pos.decrementBy(new Vector3D((g1.x - g2.x)/4 , (g1.y - g2.y) /4, (g1.z - g2.z) / 4));
				//goaldistance.scaleBy(100);
				//items[i].pos.incrementBy(goaldistance.clone());
				//items[i].pos.incrementBy(new Vector3D(goaldistance.x, goaldistance.y, goaldistance.z));
				//items[i].pos.incrementBy(new Vector3D(Math.sin(time)*10, 0,Math.sin(time)*10));
				//new Vector3D(Math.sin(time)*goaldistance.x, 0,Math.sin(time)*10)
			}
			for (i = goalNum; i < num; i++)
			{
				items[i].visable = false;
				//g1 = items[i].pos;
				//items[i].pos.incrementBy(new Vector3D(g1.x / 10, g1.y / 10, g1.z / 10));
			}
		}		
	}
	
}